import type { VxeTableGridOptions } from '@vben/plugins/vxe-table';

import type { VbenFormSchema } from '#/adapter/form';
import type { ScrapModel } from '#/api/quality/models';

/** 获取表格查询表单的字段配置。 */
export function useSearchSchema(): VbenFormSchema[] {
  return [
    {
      component: 'Input',
      componentProps: {
        allowClear: true,
      },
      fieldName: 'sn',
      label: '零件码',
    },
  ];
}

/**
 * 获取表格列配置。
 */
export function useColumns(): VxeTableGridOptions<ScrapModel>['columns'] {
  return [
    { type: 'seq', width: 60 },
    { field: 'sn', title: '零件码', minWidth: 220 },
    { field: 'wo', title: '工单编号', minWidth: 140 },
    { field: 'operationCode', title: '最近作业工序', width: 120 },
    { field: 'workstationCode', title: '最近作业工位', width: 120 },
    { field: 'scrapCategoryName', title: '原因分类', width: 120 },
    { field: 'scrapReason', title: '报废原因', minWidth: 150 },
    { field: 'createdTime', title: '报废时间', width: 150 },
  ];
}
